@import './token.less';

@steps-dot-item-icon-margin-left: (@steps-label-vertical-content-width / 2) -
  (@steps-dot-size-item-icon / 2);
@steps-dot-vertical-item-dot-margin-top-active: @steps-dot-vertical-item-dot-margin-top -
  (@steps-dot-size-item-icon-active - @steps-dot-size-item-icon);

// Dot
.@{steps-prefix-cls} {
  &-mode-dot &-item {
    flex: 1;
    white-space: nowrap;
    margin-right: @steps-dot-size-item-icon + @steps-dot-size-item-icon-gap * 2;
    position: relative;
    text-align: left;
    overflow: visible;

    &:last-child {
      flex: none;
      margin-right: 0;
    }
  }

  &-mode-dot &-item-active &-item-title {
    font-weight: @steps-dot-font-weight-item-title_active;
  }

  &-mode-dot &-item:not(&-item-active) &-item-title {
    font-weight: normal;
  }

  &-mode-dot &-item-icon {
    display: inline-block;
    box-sizing: border-box;
    width: @steps-dot-size-item-icon;
    height: @steps-dot-size-item-icon;
    border-radius: @steps-dot-border-radius-item-icon;
    vertical-align: top;
  }

  &-mode-dot &-item-active &-item-icon {
    width: @steps-dot-size-item-icon-active;
    height: @steps-dot-size-item-icon-active;
  }

  &-mode-dot &-item-wait &-item-icon {
    border-color: @steps-dot-color-item-border_wait;
    background-color: @steps-dot-color-item-bg_wait;
  }

  &-mode-dot &-item-process &-item-icon {
    border-color: @steps-dot-color-item-border_process;
    background-color: @steps-dot-color-item-bg_process;
  }

  &-mode-dot &-item-finish &-item-icon {
    border-color: @steps-dot-color-item-border_finish;
    background-color: @steps-dot-color-item-bg_finish;
  }

  &-mode-dot &-item-error &-item-icon {
    border-color: @steps-dot-color-item-border_error;
    background-color: @steps-dot-color-item-bg_error;
  }

  &-mode-dot&-horizontal &-item-icon {
    margin-left: @steps-dot-item-icon-margin-left;
  }

  &-mode-dot&-horizontal &-item-active &-item-icon {
    margin-left: @steps-dot-item-icon-margin-left -
      ((@steps-dot-size-item-icon-active - @steps-dot-size-item-icon) / 2);
    margin-top: -((@steps-dot-size-item-icon-active - @steps-dot-size-item-icon) / 2);
  }

  &-mode-dot &-item-content {
    display: inline-block;
  }

  &-mode-dot &-item-title {
    position: relative;
    display: inline-block;
    font-size: @steps-size-default-font-size-title;
    margin-top: @steps-dot-horizontal-item-title-margin-top;
  }

  &-mode-dot &-item-wait &-item-title {
    color: @steps-dot-color-item-title_wait;
  }

  &-mode-dot &-item-process &-item-title {
    color: @steps-dot-color-item-title_process;
  }

  &-mode-dot &-item-finish &-item-title {
    color: @steps-dot-color-item-title_finish;
  }

  &-mode-dot &-item-error &-item-title {
    color: @steps-dot-color-item-title_error;
  }

  &-mode-dot &-item-description {
    white-space: normal;
    font-size: @steps-size-default-font-size-description;
    margin-top: @steps-dot-horizontal-item-description-margin-top;
  }

  &-mode-dot &-item-wait &-item-description {
    color: @steps-dot-color-item-description_wait;
  }

  &-mode-dot &-item-process &-item-description {
    color: @steps-dot-color-item-description_process;
  }

  &-mode-dot &-item-finish &-item-description {
    color: @steps-dot-color-item-description_finish;
  }

  &-mode-dot &-item-error &-item-description {
    color: @steps-dot-color-item-description_error;
  }

  &-mode-dot > &-item:not(:last-child) {
    > .@{steps-prefix-cls}-item-tail {
      position: absolute;
      width: 100%;
      height: @steps-dot-size-item-tail;
      top: ((@steps-dot-size-item-icon - @steps-dot-size-item-tail) / 2);
      left: @steps-dot-item-icon-margin-left + @steps-dot-size-item-icon +
        @steps-dot-size-item-icon-gap;
      box-sizing: border-box;
      background-color: @steps-dot-color-item-tail_wait;

      &::after {
        display: none;
      }
    }
  }

  &-mode-dot &-item:not(:last-child)&-item-process &-item-tail {
    background-color: @steps-dot-color-item-tail_wait;
  }

  &-mode-dot &-item:not(:last-child)&-item-finish &-item-tail {
    background-color: @steps-dot-color-item-tail_process;
  }

  &-mode-dot &-item:not(:last-child)&-item-next-error &-item-tail {
    background-color: @steps-dot-color-item-tail_error;
  }

  // Dot vertical
  &-mode-dot&-vertical > &-item > &-item-icon {
    margin-right: @steps-dot-vertical-item-icon-margin-right;
  }

  &-mode-dot&-vertical > &-item > &-item-content {
    overflow: hidden;
  }

  &-mode-dot&-vertical &-item-title {
    margin-top: @steps-dot-vertical-item-dot-margin-top + (@steps-dot-size-item-icon / 2) -
      (@steps-size-default / 2);
  }

  &-mode-dot&-vertical&-size-small &-item-title {
    margin-top: @steps-dot-vertical-item-dot-margin-top + (@steps-dot-size-item-icon / 2) -
      (@steps-size-small / 2);
  }

  &-mode-dot&-vertical &-item-active &-item-title {
    margin-top: @steps-dot-vertical-item-dot-margin-top-active +
      (@steps-dot-size-item-icon-active / 2) - (@steps-size-default / 2);
  }

  &-mode-dot&-vertical&-size-small &-item-active &-item-title {
    margin-top: @steps-dot-vertical-item-dot-margin-top-active +
      (@steps-dot-size-item-icon-active / 2) - (@steps-size-small / 2);
  }

  &-mode-dot&-vertical &-item-description {
    margin-top: @steps-dot-vertical-item-description-margin-top;
  }

  &-mode-dot&-vertical > &-item:not(:last-child) {
    > .@{steps-prefix-cls}-item-tail {
      position: absolute;
      width: 1px;
      transform: translateX(-50%);
      top: @steps-dot-size-item-icon + @steps-dot-vertical-item-dot-margin-top +
        @steps-dot-vertical-spacing-tail-top;
      bottom: @steps-dot-vertical-spacing-tail-bottom - @steps-dot-vertical-item-dot-margin-top;
      left: (@steps-dot-size-item-icon / 2);
      background-color: transparent;
      box-sizing: border-box;
      padding: 0;
      height: unset;

      &::after {
        content: '';
        display: block;
        width: 100%;
        height: 100%;
        background-color: @steps-dot-color-item-tail_wait;
      }
    }
  }

  &-mode-dot&-vertical > &-item:not(:last-child)&-item-process {
    > .@{steps-prefix-cls}-item-tail::after {
      background-color: @steps-dot-color-item-tail_wait;
    }
  }

  &-mode-dot&-vertical > &-item:not(:last-child)&-item-finish {
    > .@{steps-prefix-cls}-item-tail::after {
      background-color: @steps-dot-color-item-tail_process;
    }
  }

  &-mode-dot&-vertical > &-item:not(:last-child)&-item-next-error {
    > .@{steps-prefix-cls}-item-tail::after {
      background-color: @steps-dot-color-item-tail_error;
    }
  }

  &-mode-dot&-vertical > &-item {
    > .@{steps-prefix-cls}-item-icon {
      margin-top: @steps-dot-vertical-item-dot-margin-top;
    }
  }

  &-mode-dot&-vertical > &-item-active {
    > .@{steps-prefix-cls}-item-icon {
      margin-top: @steps-dot-vertical-item-dot-margin-top-active;
      margin-left: -((@steps-dot-size-item-icon-active - @steps-dot-size-item-icon) / 2);
    }
  }
}

.@{steps-prefix-cls}-rtl {
  &.@{steps-prefix-cls}-mode-dot {
    .@{steps-prefix-cls}-item {
      margin-right: 0;
      margin-left: @steps-dot-size-item-icon + @steps-dot-size-item-icon-gap * 2;
      text-align: right;

      &:last-child {
        margin-left: 0;
      }

      &:not(:last-child) {
        .@{steps-prefix-cls}-item-tail {
          left: initial;
          right: @steps-dot-item-icon-margin-left + @steps-dot-size-item-icon +
            @steps-dot-size-item-icon-gap;
        }
      }
    }
  }

  &.@{steps-prefix-cls}-mode-dot.@{steps-prefix-cls}-horizontal {
    .@{steps-prefix-cls}-item-icon {
      margin-left: 0;
      margin-right: @steps-dot-item-icon-margin-left;
    }

    .@{steps-prefix-cls}-item-active .@{steps-prefix-cls}-item-icon {
      margin-left: 0;
      margin-right: @steps-dot-item-icon-margin-left -
        ((@steps-dot-size-item-icon-active - @steps-dot-size-item-icon) / 2);
    }
  }

  &.@{steps-prefix-cls}-mode-dot.@{steps-prefix-cls}-vertical {
    .@{steps-prefix-cls}-item-icon {
      margin-right: 0;
      margin-left: @steps-dot-vertical-item-icon-margin-right;
    }

    .@{steps-prefix-cls}-item:not(:last-child) .@{steps-prefix-cls}-item-tail {
      left: 0;
      right: (@steps-dot-size-item-icon / 2);
    }

    .@{steps-prefix-cls}-item-active .@{steps-prefix-cls}-item-icon {
      margin-right: -((@steps-dot-size-item-icon-active - @steps-dot-size-item-icon) / 2);
    }
  }
}
